<template>
  <TopNavBar :title="_t18('25_auth_center')" type="back" />
  
  <div class="auth-center-container">
    <div class="auth-center-top">
      <img class="auth-center-main-icon" src="/static/img/mUh_83d47db8_VaK.4e5b1e18.png" alt="auth-main" />
      <div class="auth-center-tip">{{ _t18('25_auth_tip') }}</div>
    </div>
    <div class="auth-center-list">
      <div class="auth-center-item" @click="goPrimary">
        <div class="auth-center-item-icon">
          <img src="@/assets/defi/auth.png" alt="auth" />
        </div>
        <div class="auth-center-item-label">{{ _t18('25_primary_auth') }}</div>
        <div class="auth-center-item-arrow">
          <span v-if="primaryAuth == '3'">{{ _t18('25_reviewing') }}</span>
          <span v-if="primaryAuth == '1'">{{ _t18('25_authenticated') }}</span>
          <img src="@/assets/defi/into.png" alt="auth" />
        </div>
      </div>
      <div class="auth-center-item" @click="goAdvanced">
        <div class="auth-center-item-icon">
          <img src="@/assets/defi/auth.png" alt="auth" />
        </div>
        <div class="auth-center-item-label">{{ _t18('25_advanced_auth') }}</div>
        <div class="auth-center-item-arrow">
          <span v-if="advancedAuth == '3'">{{ _t18('25_reviewing') }}</span>
          <span v-if="advancedAuth == '1'">{{ _t18('25_authenticated') }}</span>
          <img src="@/assets/defi/into.png" alt="auth" />
        </div>
      </div>
    </div>
  </div>
</template>


<script setup>
import { useRouter } from 'vue-router'
import { showToast } from 'vant'
import { useUserStore } from '@/store/user/index'
import { useI18n } from 'vue-i18n'
const { t } = useI18n() // 获取 t 函数
const _t18 = (key) => t(key) // 自定义 _t18 为翻译函数的封装
const userStore = useUserStore()
userStore.getUserInfo()

// 用户信息
const { userInfo } = storeToRefs(userStore)
const primaryAuth = ref(userInfo.value.detail?.auditStatusPrimary)
const advancedAuth = ref(userInfo.value.detail?.auditStatusAdvanced)
const router = useRouter()
function goPrimary() {
  if (primaryAuth.value == '0') {
    showToast(_t18('25_go_to_advanced_certification'))
  } else {
    router.push('/certification-primary')
  }
  
}
function goAdvanced() {
  // 只有初级认证通过（=1）才允许进入高级认证页面
  if (primaryAuth.value == '1') {
    router.push('/certification-primary') // 进入高级认证
  } else {
    showToast(_t18('25_auth_tip')) // 弹出提示：请先完成初级认证
  }
}

</script>

<style scoped lang="scss">
.auth-center-container {
  width: 100%;
  min-height: 100vh;
  background: #f7f9fa;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 40px;
}
.auth-center-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 40px;
}
.auth-center-main-icon {
  width: 160px;
  height: 120px;
  object-fit: contain;
  margin-bottom: 16px;
}
.auth-center-tip {
  color: #888;
  font-size: 16px;
  margin-bottom: 10px;
  text-align: center;
}
.auth-center-list {
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-center-item {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  padding: 16px 20px;
  cursor: pointer;
  transition: background 0.2s;
  &:hover {
    background: #f0f2f5;
  }
}
.auth-center-item-icon {
  width: 36px;
  height: 36px;
  background: #222;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.9;
  }
}
.auth-center-item-label {
  font-size: 18px;
  font-weight: 600;
  color: #222;
  flex: 1;
}
.auth-center-item-arrow {
  color: #bbb;
  font-size: 22px;
  font-weight: bold;
  // width: 54px;
  height: 24px;
  display: flex;
  align-items: center; /* 垂直居中对齐 */
  gap: 6px; /* 控制文字与图片间距 */

  span {
    font-size: 16px;
    display: inline-block;
    width: 60px; /* 固定宽度，根据文字调整 */
    text-align: right;
    color: #000;
  }
  img {
    // width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.9;
  }
}
</style> 